home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1997 January: Mac OS SDK / Dev.CD Jan 97 SDK2.toast / Development Kits (Disc 2) / OpenDoc Development Framework / ODFDev / ODF / Framewrk / FWPart / FWLink.cpp < prev    next >
Encoding:
Text File  |  1996-09-17  |  6.0 KB  |  183 lines  |  [TEXT/MPS ]

  1. //========================================================================================
  2. //
  3. //    File:                FWLink.cpp
  4. //    Release Version:    $ ODF 2 $
  5. //
  6. //    Copyright:    (c) 1993 - 1996 by Apple Computer, Inc., all rights reserved.
  7. //
  8. //========================================================================================
  9.  
  10. #include "FWFrameW.hpp"
  11.  
  12. #ifndef FWLINK_H
  13. #include "FWLink.h"
  14. #endif
  15.  
  16. // ----- Framework Includes -----
  17.  
  18. #ifndef FWPART_H
  19. #include "FWPart.h"
  20. #endif
  21.  
  22. #ifndef FWPRESEN_H
  23. #include "FWPresen.h"
  24. #endif
  25.  
  26. #ifndef FWFRAME_H
  27. #include "FWFrame.h"
  28. #endif
  29.  
  30. #ifndef FWEVENT_H
  31. #include "FWEvent.h"
  32. #endif
  33.  
  34. #ifndef FWCONTXT_H
  35. #include "FWContxt.h"
  36. #endif
  37.  
  38. // ----- OpenDoc Includes -----
  39.  
  40. #ifndef SOM_Module_OpenDoc_StdProps_defined
  41. #include <StdProps.xh>
  42. #endif
  43.  
  44. #ifndef SOM_Module_OpenDoc_StdTypes_defined
  45. #include <StdTypes.xh>
  46. #endif
  47.  
  48. //========================================================================================
  49. //    Runtime information
  50. //========================================================================================
  51.  
  52. #ifdef FW_BUILD_MAC
  53. #pragma segment odflinking
  54. #endif
  55.  
  56. //=======================================================================================
  57. //    Constants
  58. //=======================================================================================
  59.  
  60. // Bit patterns for link borders
  61. const FW_BitPattern FW_kHLinkPat = {0x00, 0x66, 0xCC, 0x00, 0x00, 0x00, 0x00, 0x00};
  62. const FW_BitPattern FW_kVLinkPat = {0x20, 0x60, 0x40, 0x00, 0x20, 0x60, 0x40, 0x00};
  63. const FW_BitPattern FW_kSelectedHLinkPat = {0x00, 0x77, 0xEE, 0x00, 0x00, 0x00, 0x00, 0x00};
  64. const FW_BitPattern FW_kSelectedVLinkPat = {0x20, 0x60, 0x60, 0x40, 0x20, 0x60, 0x60, 0x40};
  65.  
  66. //========================================================================================
  67. //    class FW_CLink
  68. //========================================================================================
  69.  
  70. //---------------------------------------------------------------------------------------
  71. //    FW_CLink constructor
  72. //---------------------------------------------------------------------------------------
  73. FW_CLink::FW_CLink(Environment* ev, FW_CPresentation* presentation)
  74. :    fPresentation(presentation),
  75.     fSelected(false),
  76.     fShowBorder(false)
  77. {
  78. FW_UNUSED(ev);
  79. }
  80.  
  81. //---------------------------------------------------------------------------------------
  82. //    FW_CLink destructor
  83. //---------------------------------------------------------------------------------------
  84. FW_CLink::~FW_CLink()
  85. {
  86. }
  87.  
  88. //---------------------------------------------------------------------------------------
  89. //    FW_CLink::DoCreateLinkBorderShape
  90. //---------------------------------------------------------------------------------------
  91. ODShape* FW_CLink::DoCreateLinkBorderShape(Environment* ev)
  92. {
  93. FW_UNUSED(ev);
  94.     // Override to create a shape for the linked data's border
  95.     return NULL;
  96. }
  97.  
  98. //---------------------------------------------------------------------------------------
  99. //    FW_CLink::DoDrawLinkBorder
  100. //---------------------------------------------------------------------------------------
  101. void FW_CLink::DoDrawLinkBorder(Environment* ev, ODShape* outline, FW_CGraphicContext& gc)
  102. {
  103.     // Override to draw border around this link
  104. FW_UNUSED(ev);
  105. FW_UNUSED(outline);
  106. FW_UNUSED(gc);
  107. }
  108.  
  109. //---------------------------------------------------------------------------------------
  110. //    FW_CLink::InvalidateBorder
  111. //---------------------------------------------------------------------------------------
  112. void FW_CLink::InvalidateBorder(Environment* ev)
  113. {
  114.     FW_CAcquiredODShape aqBorderShape = DoCreateLinkBorderShape(ev);
  115.     fPresentation->Invalidate(ev, aqBorderShape);
  116. }
  117.  
  118. //---------------------------------------------------------------------------------------
  119. //    FW_CLink::IsMouseInBorder
  120. //---------------------------------------------------------------------------------------
  121. FW_Boolean FW_CLink::IsMouseInBorder(Environment* ev, FW_CFrame* frame, const FW_CMouseEvent& theMouseEvent)
  122. {
  123.     if (!fShowBorder)
  124.         return false;
  125.  
  126.     FW_CAcquiredODShape aqLinkShape = DoCreateLinkBorderShape(ev);
  127.     if (((ODShape*)aqLinkShape) == NULL)
  128.         return false;
  129.     
  130.     FW_CPoint where = theMouseEvent.GetMousePosition(ev, FW_CMouseEvent::kFrame);
  131.     frame->GetContentView(ev)->FrameToViewContent(ev, where);
  132.     
  133.     ODPoint odWhere = where;
  134.     return aqLinkShape->ContainsPoint(ev, &odWhere);        
  135. }
  136.  
  137. //---------------------------------------------------------------------------------------
  138. //    FW_CLink::ShowHideLinkBorder
  139. //---------------------------------------------------------------------------------------
  140. void FW_CLink::ShowHideLinkBorder(Environment* ev, FW_Boolean turnOn, ODFacet* facet)
  141. {
  142.     // "Show Links" setting changed; draw borders as appropriate
  143.     this->SetSelectState(ev, false);    // de-select
  144.     this->SetShowBorder(ev, turnOn);
  145.  
  146.     if (turnOn)
  147.         this->DrawLinkBorder(ev, facet);
  148. }
  149.  
  150. //---------------------------------------------------------------------------------------
  151. //    FW_CLink::DrawLinkBorder
  152. //---------------------------------------------------------------------------------------
  153. void FW_CLink::DrawLinkBorder(Environment* ev, ODFacet* facet)
  154. {
  155.     // Redraw border using the current setting (fSelected)
  156.     FW_CAcquiredODShape aqOutline = DoCreateLinkBorderShape(ev);
  157.     if (((ODShape*)aqOutline) != NULL)
  158.         if (!aqOutline->IsEmpty(ev))
  159.         {
  160.             FW_CViewContext fc(ev, NULL, facet);        // the content view will be used
  161.             this->DoDrawLinkBorder(ev, aqOutline, fc);
  162.         }
  163. }
  164.  
  165. //---------------------------------------------------------------------------------------
  166. //    FW_CLink::Select
  167. //---------------------------------------------------------------------------------------
  168. void FW_CLink::Select(Environment* ev, FW_Boolean newState)
  169. {
  170.     this->SetSelectState(ev, newState);
  171.     this->SelectionChanged(ev, newState);
  172. }
  173.  
  174. //---------------------------------------------------------------------------------------
  175. //    FW_CLink::SelectionChanged
  176. //---------------------------------------------------------------------------------------
  177. void FW_CLink::SelectionChanged(Environment* ev, FW_Boolean newState)
  178. {
  179. FW_UNUSED(ev);
  180. FW_UNUSED(newState);
  181.     // Override to do part-specific stuff when a link has been selected or de-selected
  182. }
  183.